<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.augmentum.login.Constants"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="com.augmentum.login.model.Exam"%>
<%@page import="com.augmentum.login.model.Page"%>
<%@ page import="com.augmentum.login.util.Prop"%>
  <% String basePath = request.getContextPath();
     String staticPath = Prop.get(Constants.STATIC_PATH);
  %>

  <script type="text/javascript">
    $(document).ready(function(){
        $("#confirmDelete").click(function(){
            var url = '<%=basePath%>' + "/page/exam/delete";
            deleteExam(url , 'state', 'examStr', 0, checkBox('selectedId'));
          });
    });
  </script>
  <div style="width:100%;" class="common float-left">
    <div class="common common-width" style="height:50px">
      <div class="common common-height float-left" style="width:25%"></div>
        <% String description= (String)request.getAttribute(Constants.DESCRIPTION);
            String order= (String)request.getAttribute(Constants.ORDER);
            String examName= (String)request.getAttribute(Constants.EXAM_NAME);
            Page p = (Page)request.getAttribute(Constants.PAGE);
            int pageCount = p.getPageCount();
            int currentPage = p.getCurrentPage();
            int pageSize = p.getPageSize();
        %>
      <div class="common common-height layout-center float-left" style="width:50%">
        <table style="width:80%;margin:auto" class="font-style06 color-style06">
          <tr>
            <td>
              <%if (!p.isFirstPage() && p.getPageCount() > 1) {%>
              <a title="Go to previous page!" class="astyle" href="<%= basePath%>/page/exam/draftSearch?currentPage=<%= currentPage - 1%>&examName=<%= examName%>&pageSize=<%= pageSize%>">
                <img alt="LEFT" src="<%= staticPath%>/images/BTN_PageLeft_20x15.png">
              </a>
              <%} else {%>
                  <img class="img-style" alt="left image" title="No privious page!" src="<%= staticPath%>/images/BTN_PageLeft_20x15.png">
              <%}%>
            </td>
            <% if (pageCount != 0) {
                   if (pageCount < 5) {
                       int i=0;
                       for (i=1; i <= pageCount; i++) {
            %>
            <td class="font-style06">
                <a class="a-style01 color-style07" title="Go to the first page!" href="<%= basePath%>/page/exam/draftSearch?currentPage=<%= i%>&examName=<%= examName%>&pageSize=<%= p.getPageSize()%>">
                  <span><%= i%></span>
                </a>
            </td>
            <% }
              } else if (currentPage < pageCount - 4){ 
                   %>
            <td class="font-style06">
              <a class="a-style01 color-style07" href="<%= basePath%>/page/exam/draftSearch?currentPage=<%= currentPage%>&examName=<%= examName%>&pageSize=<%= p.getPageSize()%>">
                <%= currentPage%>
              </a>
            </td>
            <td class="font-style06">
              <a class="a-style01 color-style07" href="<%= basePath%>/page/exam/draftSearch?currentPage=<%= currentPage + 1%>&examName=<%= examName%>&pageSize=<%= p.getPageSize()%>">
                <%= currentPage + 1%>
              </a>
            </td>
            <td class="font-style06">
              <a class="a-style01 color-style07" href="<%= basePath%>/page/exam/draftSearch?currentPage=<%= currentPage + 2%>&examName=<%= examName%>&pageSize=<%= p.getPageSize()%>">
                <%= currentPage + 2%>
              </a>
            </td>
            <td class="font-style06">
              <a class="a-style01 color-style07" href="<%= basePath%>/page/exam/draftSearch?currentPage=<%= currentPage + 3%>&examName=<%= examName%>&pageSize=<%= p.getPageSize()%>">...</a>
            </td>
            <td class="font-style06">
              <a class="a-style01 color-style07" href="<%= basePath%>/page/exam/draftSearch?currentPage=<%= p.getPageCount()%>&examName=<%= examName%>&pageSize=<%= p.getPageSize()%>">
                <span title="Go to the last page!"><%= p.getPageCount()%></span>
              </a>
            </td>
            <% } else {%>
            <td class="a-style01 color-style07" class="font-style06">
              <a class="a-style01 color-style07" href="<%= basePath%>/page/exam/draftSearch?currentPage=<%= 1%>&examName=<%= examName%>&pageSize=<%= p.getPageSize()%>">
              ...
              </a>
            </td>
            <td class="font-style06">
              <a class="a-style01 color-style07" href="<%= basePath%>/page/exam/draftSearch?currentPage=<%= pageCount - 3%>&examName=<%= examName%>&pageSize=<%= p.getPageSize()%>">
                <%= pageCount - 3%>
              </a>
            </td>
            <td class="font-style06">
              <a class="a-style01 color-style07" href="<%= basePath%>/page/exam/draftSearch?currentPage=<%= pageCount - 2%>&examName=<%= examName%>&pageSize=<%= p.getPageSize()%>">
                <%= pageCount - 2%>
              </a>
            </td>
            <td class="font-style06">
              <a class="a-style01 color-style07" href="<%= basePath%>/page/exam/draftSearch?currentPage=<%= pageCount - 1%>&examName=<%= examName%>&pageSize=<%= p.getPageSize()%>">
                <%= pageCount - 1%>
              </a>
            </td>
            <td class="font-style06">
               <% if (!p.isLastPage()) { %>
                <a class="a-style01 color-style07" href="<%= basePath%>/page/exam/draftSearch?currentPage=<%= pageCount%>&examName=<%= examName%>&pageSize=<%= p.getPageSize()%>">
                  <span title="Go to the last page!"><%= pageCount%></span>
                </a>
               <%} else {%>
                 <span title="It has been the last page!" style="color:gray;"><%= p.getPageCount()%></span>
               <%}%>
            </td>
            <% }}%>
            <td>
              <%if (!p.isLastPage() && p.getPageCount() > 1) {%>
              <a title="Go to previous page!" class="astyle" href="<%= basePath%>/page/exam/draftSearch?currentPage=<%= currentPage + 1%>&examName=<%= examName%>&pageSize=<%= pageSize%>">
                <img alt="LEFT" src="<%= staticPath%>/images/BTN_PageRight_20x15.png">
              </a>
              <%} else {%>
                  <img class="img-style" alt="left image" title="No privious page!" src="<%= staticPath%>/images/BTN_PageRight_20x15.png">
              <%}%>
            </td>
            <td style="width:100px">
              <select style="cursor:pointer;color:#FE9901" id="sid" onchange="searchDraft('<%= basePath%>/page/exam/draftSearch', 'currentPage', 'pageSize', 'examName', '<%= p.getCurrentPage()%>', this.value, '<%= examName%>')">
                <option value="10">10</option>
                <option value="15">15</option>
                <option value="20">20</option>
               </select>
               <script type="text/javascript">
                 var optionArray = document.getElementById("sid").options;
                 for(var i = 0; i < optionArray.length; i++) {
                   var b = optionArray[i].value == <%= p.getPageSize()%>;
                   if(b) {
                       optionArray[i].selected = 'selected';
                    }
                  }
              </script>per page
            </td>
            <td style="width:80px;">
              <form name="pageForm" class="common-length" action="<%= basePath%>/page/exam/draftSearch" method="post">
                <input style="width:20px;height:15px;border: 1px solid" class="color-style06 radius3" type="text" name="currentPage" />
                <input type="hidden" name="pageSize" value="<%= p.getPageSize()%>" />
                <input type="hidden" name="examName" value="<%= examName%>" />
                <span class="radius3" onclick= "javascipt:document.pageForm.submit();" style="background:orange;color:white;cursor:pointer;padding:1px;">Go</span>
              </form>
            </td>
          </tr>
        </table>
      </div>
      <div class="common common-height float-left" style="width:25%">
        <span class="showbtn float-right layout-center radius3" style="margin-right:10px;margin-top:15px;cursor:pointer;width:100px;height:60%;color:white;background:orange;">
          Delete
        </span>
      </div>
    </div>
  </div>
  <jsp:include page="../frame.jsp"></jsp:include>
 